package cur.nature.framework.mvc.http;

import cur.nature.tinyorm.core.bean.PageBean;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@Schema(description = "请求参数")
public class RequestObject {
    @Schema(description = "系统ID(默认:api)")
    private String systemId="api";
    @Schema(description = "版本信息(默认:1)")
    private Long version=1L;

    @Data
    @EqualsAndHashCode(callSuper=true)
    @Tag(name = "分页组件")
    public static class PageRequest extends RequestObject{
        @Schema(description = "当前页")
        private long pageNum = 1;
        @Schema(description = "每页记录数")
        private long pageSize = 10;
        @Schema(description = "总记录数")
        private long total;

        public PageBean buildPage(){
            PageBean pageBean = new PageBean();
            pageBean.setPageNum(pageNum);
            pageBean.setPageSize(pageSize);
            pageBean.setTotal(total);
            return pageBean;
        }

        public void maxPage(){
            this.setPageNum(1);
            this.setPageSize(Integer.MAX_VALUE);
        }
    }
}
